﻿using System;
using System.Text;
using Flowertwig.Utils.Hashing;

namespace Org.Flowertwig.Media
{
    public class Hash
    {
        public static string CreateId(string content)
        {
            var t = new Tiger();
            t.Initialize();

            var id = Convert.ToBase64String(t.ComputeHash(Encoding.UTF8.GetBytes(content)));

            // Filesystem doesn't allow + and / so we will replace it with something else.
            var safeId = id.Replace('+', '-').Replace('/', '_');
            return safeId;
        }
    }
}
